package com.supplychain.scm.core.oss.rule;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.supplychain.scm.core.basis.constant.StringPool;
import com.supplychain.scm.core.oss.util.FileUtil;
import lombok.AllArgsConstructor;
import org.dromara.dynamictp.common.util.StringUtil;

/**
 * 默认上传规则
 * @author veliger
 * create on 2022-03-14
 */
@AllArgsConstructor
public class DbyOssRule implements OssRule {
	@Override
	public String bucketName(String bucketName) {
		return bucketName;
	}

	@Override
	public String fileName(String prefix,String originalFilename) {
		String pre = StringUtil.isEmpty(prefix) ? "upload" : prefix;
		return pre+ StringPool.SLASH + DateUtil.today().replace(StringPool.DASH, StringPool.SLASH) + StringPool.SLASH + IdUtil.fastSimpleUUID() + StringPool.DOT + FileUtil.getFileExtension(originalFilename);
	}
}
